package com.unicom.si.service;

import com.unicom.si.pojo.Dept;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.stereotype.Service;

@Service
public class DeptService {

    @PreAuthorize("hasRole('ROLE_TEST')")
    public Dept queryDeptService(int deptid) {

        Dept dept = new Dept();

        if(deptid == 1) {
            dept.setDeptid(9999);
            dept.setCompid(69);
            dept.setDeptname("管理信息产品部111");
        } else {
            dept.setDeptid(10);
            dept.setCompid(69);
            dept.setDeptname("财务部");
        }

        return dept;
    }

    // 根据表达式判断
    @PreAuthorize("#id == 1")
    public Dept checkDeptId(int id) {
        Dept dept = new Dept();
        dept.setDeptid(9999);
        dept.setCompid(69);
        dept.setDeptname("管理信息产品部123");

        return dept;

    }
}
